package org.itzheng.yuezhi.adapter;

import android.bluetooth.BluetoothDevice;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import org.itzheng.yuezhi.R;
import org.itzheng.yuezhi.utils.comm.UIUtils;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by admin on 2017/8/7.
 */

public class BluetoothListRcvAdapter extends BaseRecyclerViewAdapter<BluetoothListRcvAdapter.ViewHolder> {
    List<BluetoothDevice> mItems;

    public BluetoothListRcvAdapter(List<BluetoothDevice> noBondBluetooth) {
        mItems = noBondBluetooth;

    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new ViewHolder(UIUtils.inflate(R.layout.adapter_item_search_bluetooth));
    }

    @Override
    public int getItemCount() {
        return mItems == null ? 0 : mItems.size();
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position, boolean isBaseRecyclerViewAdapter) {
        BluetoothDevice device = mItems.get(position);
        holder.tvName.setText("" + device.getName());
        holder.tvAddress.setText("" + device.getAddress());
    }

    public class ViewHolder extends RecyclerView.ViewHolder {

        @BindView(R.id.tvName)
        TextView tvName;
        @BindView(R.id.tvAddress)
        TextView tvAddress;

        public ViewHolder(View itemView) {
            super(itemView);
            bindButterKnife();

        }

        private void bindButterKnife() {
            ButterKnife.bind(this, itemView);
        }
    }
}
